<template>
	<view class="all">
		<!--标签导航 -->
		<view class="titi">
			<image class="im2" :src="srcUrl1()" style="width: 120rpx; height: 120rpx;"></image>
			<image class="name" :src="srcUrl2()" style="width: 300rpx; height: 120rpx;"></image>
		</view>
		
		<swiper acceleration="true" autoplay="true" class="lunb" indicator-dots="true" indicator-active-color="#ffff">
			<swiper-item v-for="(item,index) in rotation" :key="index">
				<image class="img5" :src="srcUrl(item.path)"></image> 
			</swiper-item>
			
		</swiper>
		<view class="li">
			<view class="bq">
				<navigator url="video">
					<image class="im1" src="../../static/images/cucoloris.png" style="width: 75rpx; height: 75rpx;"></image>
					<view class="name1">民大剪影</view>
				</navigator>
			</view>
			<view class="bq">
				<navigator url="xinx">
					<image class="im1" src="../../static/images/anniversary.png" style="width: 75rpx; height: 75rpx;"></image>
					<view class="name1">校庆新闻</view>
				</navigator>
			</view>
			<view class="bq">
				<navigator url="entity">
					<image class="im1" src="../../static/images/activity.png" style="width: 75rpx; height: 75rpx;"></image>
					<view class="name1">校庆活动</view>
				</navigator>
			</view>
			<view class="bq">
				<navigator url="leader">
					<image class="im1" src="../../static/images/leader.png" style="width:75rpx; height: 75rpx;"></image>
					<view class="name1">历任领导</view>
				</navigator>
			</view>
			<view class="bq">
				<navigator url="cory">
					<image class="im1" src="../../static/images/alumnus.png" style="width: 75rpx; height: 75rpx;"></image>
					<view class="name1">杰出校友</view>
				</navigator>
			</view>
			<view class="bq">
				<navigator url="dept">
					<image class="im1" src="../../static/images/department.png" style="width: 75rpx; height: 75rpx;"></image>
					<view class="name1">部门信息</view>
				</navigator>
			</view>
		</view>

		<view class="tab">
			<navigator url="xinx">
				<view class="tr">
					<image class="im" :src="srcUrl3()" style="width: 70rpx; height: 70rpx;"></image>
					<view class="tit">校庆新闻</view>
					<image class="imga" src="../../static/images/more.png" style="width: 30rpx; height: 30rpx;"></image>
				</view>
			</navigator>
			<view v-if="snew.length >0">
				<view class="tabl" v-for="(item,index) in snew" :key="index">
					<navigator :url="'detail?id='+item.id">
						<view class="tex">
							<view class="tex1">{{item.name.length>15 ? item.name.substring(0,15)+'...' : item.name}}</view>
							<view class="tex4">{{updateTime[index]}}</view>
						</view>
					</navigator>
				</view>
			</view>
			<view v-else class="t1">暂无校庆信息，敬请期待!!!</view>
		</view>
		<view class="tab">
			<navigator url="entity">
				<view class="tr">
					<image class="im" :src="srcUrl3()" style="width: 70rpx; height: 70rpx;"></image>
					<view class="tit">校庆活动</view>
					<image class="imga" src="../../static/images/more.png" style="width: 30rpx; height: 30rpx;"></image>
				</view>
			</navigator>
				<!-- <view class="table"> -->
				<view v-if="activities.length >0">
					<view class="tabl" v-for="(item,index) in activities" :key="index">
						<navigator :url="'Edetail?id='+item.id">
							<view class="tex">
								<view class="tex1">{{item.name.length>15 ? item.name.substring(0,15)+'...' : item.name}}</view>
								<view class="tex4">{{updateTime1[index]}}</view>
							</view>
						</navigator>
					</view>
				</view>
				<view v-else class="t1">暂无校庆活动，敬请期待!!!</view>
				<!-- </view> -->
			
		</view>
		<view class="tab">
			<view class="tr">
				<image class="im" :src="srcUrl3()" style="width: 70rpx; height: 70rpx;"></image>
				<view class="tit">最新认证</view>
				<image class="imga" src="../../static/images/more.png" style="width: 30rpx; height: 30rpx;"></image>
			</view>
			<view v-if="newUser.length >0">
				<view class="list1">
					<view v-for="(item,index) in newUser" :key="index">
						<image class="ima1" :src="item.avatar_url" style="width: 100rpx; height: 100rpx;"></image>
						<!-- <view class="text4">{{item.avatar_name}}</view> -->
					</view>
				</view>
			</view>
			<view v-else class="t1" >暂无认证人员，请稍后查看!!!</view>
		</view>
	</view>
</template>

<script>
	export default{
		data()	{
			return	{
				snew:[],
				activities:[],
				size:3,
				page:0,
				updateTime:[],
				updateTime1:[],
				size1:4,
				rotation:[],
				newUser:[]
			}
		},
		onShow(){
			uni.request({
					url:getApp().globalData.URL+"news/findByNewest?page="+this.page+"&size="+this.size,
					method:'GET'
				})
			.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
				var [error, res]  = data;
				console.log("news/findByNewest", res.data);
				this.snew = res.data;
				for(var i = 0;i<res.data.length;i++){
					
					//修改时间转换(将时间戳转换成yyyy-MM-dd)
					this.updateTime[i] = this.happenTimeFun(res.data[i].update_time);
				}
				
			})
			
			uni.request({
					url:getApp().globalData.URL+"photos/findByRotation?page="+this.page+"&size="+this.size1,
					method:'GET'
				})
			.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
				var [error, res]  = data;
				console.log("photos/findByRotation",res.data);
				this.rotation = res.data;
				
			})
			
			uni.request({
					url:getApp().globalData.URL+"users/findByNewUsers?page="+this.page+"&size="+this.size1,
					method:'GET'
				})
			.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
				var [error, res]  = data;
				console.log("users/findByNewUsers", res.data);
				this.newUser = res.data;
				
			})
			
			uni.request({
					url:getApp().globalData.URL+"activities/findByActivities?page="+this.page+"&size="+this.size,
					method:'GET'
				})
			.then(data => {//data为一个数组，数组第一项为错误信息，第二项为返回数据
				var [error, res]  = data;
				console.log("activities/findByActivities", res.data);
				this.activities = res.data;
				for(var i = 0;i<res.data.length;i++){					
					//修改时间转换(将时间戳转换成yyyy-MM-dd)
					this.updateTime1[i] = this.happenTimeFun(res.data[i].update_time);
				}
				
			})
		},
		methods:{
			happenTimeFun(num){//时间戳数据处理
				 let date = new Date(parseInt(num));
				 //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				 let y = date.getFullYear();
				 let MM = date.getMonth() + 1;
				 MM = MM < 10 ? ('0' + MM) : MM;//月补0
				 let d = date.getDate();
				 d = d < 10 ? ('0' + d) : d;//天补0
				 let h = date.getHours();
				 h = h < 10 ? ('0' + h) : h;//小时补0
				 let m = date.getMinutes();
				 m = m < 10 ? ('0' + m) : m;//分钟补0
				 let s = date.getSeconds();
				 s = s < 10 ? ('0' + s) : s;//秒补0
				 return y + '-' + MM + '-' + d; //年月日时分秒
				 },
			srcUrl:function(path){
				return getApp().globalData.Link+'upload/图片/'+path;
			},
			srcUrl1:function(){
				return getApp().globalData.Link+'upload/图片/校徽白色.png';
			},
			srcUrl2:function(){
				return getApp().globalData.Link+'file/system/贵州民族大学校名-白色.png';
			},
			srcUrl3:function(){
				return getApp().globalData.Link+'upload/图片/xiaohui.png';
			}
		}
	}
</script>

<style>
	.text4{
		margin-left: 68rpx;
	}
	
	.titi {
		height: 400rpx;
		background-color: #255BBA;
		display: flex;

	}
	
	.t1{
		padding-bottom: 100rpx;
		margin-top: 100rpx;
		text-align: center;
	}

	.list1 {
		/* width: auto; */
		display: flex;
	}
	

	.tabl {
		height: 50rpx;
	}

	.ima1 {
		border-radius: 50%;
		margin: 10rpx;
		border: solid 1rpx #255BBA;
	}

	.im2 {
		width: 100%;
		height: 150rpx;
		margin: 20rpx 20rpx;
	}

	.all {
		background-color: #F1F1F1;
	}

	.li {
		display: flex;
		/* margin-top: 10rpx; */
	}

	.text {
		width: 100%;
		height: 80rpx;
		margin-left: 20rpx;
		margin-top: -25rpx;
	}

	.bq {
		height: 150rpx;
		background-color: #FFFFFF;
		width: 15%;
		margin-left: 10rpx;
		border-radius: 5%;
		margin-top: 10rpx;
	}

	.table {
		display: flex;
		margin: 20rpx 20rpx;
		height: 150rpx;
		border-bottom: 1px solid #BBBBBB;
	}

	.im1 {
		margin-left: 20rpx;
		margin-top: 10rpx;
	}

	.name1 {
		font-size: 25rpx;
		text-align: center;
		margin-top: 10rpx;
	}

	.lunb {
		width: 95%;
		margin-left: 20rpx;
		margin-top: -240rpx;
		height: 380rpx;
	}


	.tit {
		margin: 20rpx;
	}

	.tab {
		background-color: #FFFFFF;
		width: 95%;
		color: #3F536E;
		border-radius: 10rpx;
		height: auto;
		margin: 20rpx;
	}

	.tr {
		display: flex;
		border-bottom: 1px solid #BBBBBB;
		height: 95rpx;
	}

	.im {
		margin-top: 10rpx;
	}

	.tex {
		font-size: 25rpx;
		color: #007AFF;
		margin-top: 25rpx;
		/* margin-left: 10rpx; */
		width: 95%;
		display: flex;
	}

	.tex5 {
		font-size: 28rpx;
		color: #007AFF;
		margin-top: 20rpx;
		margin-left: -10rpx;
		display: flex;
	}

	.tex1 {
		font-size: 25rpx;
		color: #255BBA;
		margin-left: -15rpx;
		margin-top: 3rpx;
		text-indent: 2em;
		
		
	}

	.imga {
		margin-top: 30rpx;
		margin-left: 410rpx;
	}

	.img5 {
		width: 100%;
		height: 400rpx;
		border-radius: 30rpx;
		margin-top: 10rpx;
	}

	.name {
		margin-left: 10rpx;
		margin-top: 30rpx;
	}

	.tex2 {
		font-size: 25rpx;
		color: #555555;
		margin-left: 40rpx;
	}

	.tex3 {
		font-size: 20rpx;
		color: #555555;
		margin-top: 5rpx;
		margin-left: 195rpx;
	}
	.tex7 {
		font-size: 20rpx;
		color: #555555;
		margin-top: 5rpx;
		margin-left: 175rpx;
	}

	.tex4 {
		font-size: 25rpx;
		color: #555555;
		/* margin-top: 10rpx; */
		margin-left: auto;
		
		
	}

	.tit1 {
		margin-top: 20rpx;
	}

	.tab1 {
		background-color: #FFFFFF;
		width: 95%;
		margin-left: 20rpx;
		color: #333333;
		border-radius: 5%;
		margin-top: 20rpx;
		border-bottom-color: 1px solid #007AFF;
	}

	.tr1 {
		display: flex;
	}

	.img1 {
		width: 100%;
		height: 300rpx;
	}

	.imga1 {
		margin-top: 30rpx;
		margin-left: 400rpx;
	}

	.lis {
		display: flex;
		margin: 10rpx 10rpx;
	}

	.list {
		width: 200rpx;
	}

	.ima {
		margin-left: 20rpx;
		border-radius: 5%;
	}

	.name {
		/* margin-left: 20rpx; */
		text-align: center;
		font-size: 18rpx;
	}

	.imga2 {
		margin-top: 30rpx;
		margin-left: 430rpx;
	}

	.tit2 {
		margin-top: 20rpx;
		color: #007AFF;
	}

	.vid {
		/* width: 650rpx; */
		height: 400rpx;
		margin-left: 40rpx;
		margin-top: -240rpx;
		border-radius: 3%;
		width: 90%;
		box-shadow: 2px 2rpx 6rpx 2rpx #FFFFFF;
	}

	.ty {
		text-align: center;
		color: #3F536E;
		margin-left: 50rpx;
	}
</style>
